package com.example.springboot_study.entity.primary;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * @author : liqun
 * @createTime : 2021/9/1 10:18
 */
@ApiModel(description = "用户实体类", value = "User")
@Data
@NoArgsConstructor
@AllArgsConstructor
@JacksonXmlRootElement(localName = "User")
@Entity
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(name = "id", value = "编号",position = 1, required = false, example = "1")
    @JacksonXmlProperty(localName = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ApiModelProperty(name = "name", value = "姓名",position = 2, required = false, example = "吓抖抖")
    @NotNull
    @Size(min = 2, max = 5)
    @JacksonXmlProperty(localName = "name")
    private String name;

    @ApiModelProperty(name = "age", value = "年龄",position = 3, required = false, example = "3")
    @NotNull
    @Max(50)
    @Min(10)
    @JacksonXmlProperty(localName = "age")
    private Integer age;

    /*@ApiModelProperty(name = "email",value = "用户邮箱",position = 4)
    @NotNull
    @Email
    @JacksonXmlProperty(localName = "email")
    private String email;*/

    public User(String name, Integer age) {
        this.name = name;
        this.age = age;
    }
}
